<template>
    <ul class="subbox_top" ref="subbox_top">
        <li v-for="(item, index) in btns" :key="index">
            <span @click="HandClick(item)">{{item.name}}</span>
        </li>
        <Fil :filVisible.sync="filVisible"></Fil>
        <PsD :psDVisible.sync="psDVisible"></PsD>
    </ul>
</template>
<script>
import { Del } from '@/api/index';
import Fil from './Fil/Fil';
import PsD from './psD/psD';
export default {
    props: ['ClickselectList', 'GetHeaderFun', 'tablebody'],
    name: 'subboxTop',
    data() {
        return {
            //按钮组
            btns: [
                { name: '新增', clickBtn: 'add' },
                { name: '审核', clickBtn: 'aud' },
                { name: '删除', clickBtn: 'del' },
                { name: '下推', clickBtn: 'psD' },
                { name: '过滤', clickBtn: 'fil' }
            ],
            filVisible: false,//过滤的模态框
            psDVisible: false//下推的模态框
        };
    },
    methods: {
        //按钮组的方法
        HandClick(item) {
            switch (item.clickBtn) {
                case 'add':
                    this.$router.push({ path: '/Addup', query: this.tablebody });
                    break;
                case 'aud':
                    console.log('审核');
                    break;
                case 'del':
                    let Listselect = [];
                    this.ClickselectList.forEach((v, i) => {
                        Listselect.push(v.id);
                    });
                    Listselect = Array.from(new Set(Listselect));
                    let obj = {
                        identification: allList.tabIdentification,
                        ids: Listselect,
                        onlyDelEntity: false,
                        tableId: allList.tabId
                    };

                    Del(obj).then(({ data }) => {
                        if (data.code == 0) {
                            this.$message({
                                showClose: true,
                                message: data.msg,
                                type: 'success'
                            });
                            this.GetHeaderFun(allList.tabId);
                        }
                    });
                    break;
                case 'psD':
                    this.psDVisible = true;
                    console.log('下推');
                    break;
                case 'fil':
                    this.filVisible = true;
                    console.log('过滤');
                    break;
                default:
                    break;
            }
        }
    },
    components: {
        Fil,
        PsD
    }
};
</script>

<style lang="less" scoped>
.subbox_top {
    width: 100%;
    line-height: 30px;
    display: flex;
    margin-bottom: 15px;
    li {
        width: 80px;
        line-height: 27px;
        cursor: pointer;
        span {
            background: linear-gradient(to right, #4672f8, #6f6ffa);
            color: #fff;
            padding: 5px 15px;
            box-sizing: border-box;
            border-radius: 13.5px;
        }
    }
    li:nth-child(1) {
        margin-left: 15px;
    }
}
</style>